package xarticle

import (
	"time"

	"gitee.com/xiaoyutab/xgotool/optional/xnsq"
	"gitee.com/xiaoyutab/xgotool/xerror"
)

// 添加文章浏览量
//
//	id	文章ID
//	uid	浏览用户ID
//	ip	浏览用户IP地址
func Brow(id, uid uint, ip string) error {
	if _default.DB == nil {
		return xerror.New("数据库未连接")
	}
	article := ArticleBrowse{
		ArticleId: id,
		UserId:    uid,
		Ip:        ip,
		CreatedAt: time.Now().Format(time.DateTime),
	}
	xnsq.Set("xarticle.brow", article)
	return nil
}
